package com.example.yilanchatserver.business.freechat;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
public class BaseResponseEntity<T> {
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @JsonProperty("code")
    private Integer code;

    private String type;

    private String message;

    private T result;

    public static <T> BaseResponseEntity<T> SUCCESS(T data){
        BaseResponseEntity baseResponse = new BaseResponseEntity();
        baseResponse.setMessage("OK");
        baseResponse.setType("success");
        baseResponse.setResult(data);
        baseResponse.setCode(0000);
        return baseResponse;
    }

    public static <T> BaseResponseEntity<T> FINISH(){
        BaseResponseEntity baseResponse = new BaseResponseEntity();
        baseResponse.setMessage("finish");
        baseResponse.setType("success");
        baseResponse.setResult("");
        baseResponse.setCode(0000);
        return baseResponse;
    }

    public static <T> BaseResponseEntity<T> ERROR(){
        BaseResponseEntity baseResponse = new BaseResponseEntity();
        baseResponse.setMessage("error");
        baseResponse.setType("fail");
        baseResponse.setResult("");
        baseResponse.setCode(0003);
        return baseResponse;
    }

    public static <T> BaseResponseEntity<T> ERROR(T data){
        BaseResponseEntity baseResponse = new BaseResponseEntity();
        baseResponse.setMessage("error");
        baseResponse.setType("fail");
        baseResponse.setResult(data);
        baseResponse.setCode(0003);
        return baseResponse;
    }
    public static <T> BaseResponseEntity<T> SUCCESS(){
        return SUCCESS(null);
    }
}
